package com.lht.admin.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lht.admin.utils.QueryPlus;
import com.lht.admin.dao.OrderFollowDao;
import com.lht.admin.entity.OrderFollowEntity;
import com.lht.admin.service.OrderFollowService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * 订单跟进记录表Service实现类
 *
 * @author ZhengZhanWu
 * @date 2020-02-16 19:15:24
 */
@Service("orderFollowService")
public class OrderFollowServiceImpl extends ServiceImpl<OrderFollowDao, OrderFollowEntity> implements OrderFollowService {

    @Override
    public List<OrderFollowEntity> queryAll(Map<String, Object> params) {
        return baseMapper.queryAll(params);
    }

    @Override
    public Page queryPage(Map<String, Object> params) {
        //排序
        params.put("sidx", "T.id");
        params.put("asc", false);
        Page<OrderFollowEntity> page = new QueryPlus<OrderFollowEntity>(params).getPage();
        return page.setRecords(baseMapper.selectOrderFollowPage(page, params));
    }

    @Override
    public boolean add(OrderFollowEntity orderFollow) {
        return this.save(orderFollow);
    }

    @Override
    public boolean update(OrderFollowEntity orderFollow) {
        return this.updateById(orderFollow);
    }

    @Override
    public boolean delete(Long id) {
        return this.removeById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteBatch(Long[] ids) {
        return this.removeByIds(Arrays.asList(ids));
    }
}
